/***
    Amrita ITEWS - Copyright (C) 2009 Amrita Vishwa Vidyapeetham, Amritapuri.
                                       (http://www.amrita.edu)
    ***************************************************************************
    This file is part of the Amrita ITEWS distribution.
    Amrita ITEWS is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License (version 2) as published
    by the Free Software Foundation AND MODIFIED BY the Amrita ITEWS exception.
    ***NOTE*** The exception to the GPL is included to allow you to distribute
    a combined work that includes Amrita ITEWS without being obliged to provide
    the source code for proprietary components outside of the Amrita ITEWS
    software. Amrita ITEWS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
    Public License for more details. You should have received a copy of the GNU
    General Public License and the Amrita ITEWS license exception along with
    Amrita ITEWS if not then it can be viewed here:
    http://itews.amrita.ac.in/license.html.

    Note: This software is closely coupled to FreeRTOS and hence the
    licensing terms of FreeRTOS would apply.


    Documentation, latest information, license and contact details are at:
    http://itews.amrita.ac.in/


    Amrita ITEWS source code can be found at:
    http://code.google.com/p/itews


    The initial code-base of Amrita ITEWS was developed by Amrita Vishwa
    Vidyapeetham as part of the project titled,"Intelligent & Interactive
    Telematics using Emerging Wireless Technologies for Transport Systems
    (ITEWS)" sponsored by Technology Information Forecasting and Assessment
    Council (TIFAC), India.
***/

/*! \file serial.h
    \brief Serial Library Routines Header File.
*/
#ifndef SERIAL_H_
#define SERIAL_H_


/*! \brief Data Link Escape CHaracter.*/
#define SER_DLE_CHAR                0x10

/*! \brief Connection Close CHaracter.*/
#define SER_CLS_CHAR                0x03


/*! \brief Serial Device Odd Parity Flag.*/
#define SER_PARITY_O                'O'

/*! \brief Serial Device Even Parity Flag.*/
#define SER_PARITY_E                'E'

/*! \brief Serial Device No Parity Flag.*/
#define SER_PARITY_N                'N'

/*! \brief Serial Device in Synchronous Mode.*/
#define SER_SYNC_MODE               'S'

/*! \brief Serial Device in Asynchronous Mode.*/
#define SER_ASYNC_MODE              'A'

/*! \brief Serial Read Timeout.*/
#define SER_READ_TIMEOUT            0

/*! \brief Serial DLE Escape.*/
#define SER_DLE_RECVD               2

/*! \brief Serial Buffer Maximum Size.*/
#define SER_MAX_BUF                 32


/*! \brief Opens serial port. Returns handle >= 0 if success or error code < 0 if error. */
int32 serial_open (uint8 port, uint32 mode);
int32 serial_close( int32 port);

/* Synchronous Routines*/
int32 serial_read(int32 port, int8 *buf, int32 nread);
int32 serial_write(int32  port, const int8 *buf, int32 nwrite);
int32 serial_timed_read(int32 port, int8 *buf, int32 nread, int32 msecs);


#endif /*SERIAL_H_*/
